import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import BlogDetail from "@/views/blog/BlogDetail";
import BlogList from "@/views/blog/BlogList";
import Timeline from "@/views/timeline/Timeline";
import MomentList from "../../../blog-cms/src/views/modules/blog/moment/MomentList";
import Moment from "../../../blog-front/src/components/moment/moment";
import Friend from "../../../blog-front/src/views/friend/Friend";


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children:[
      {
        path: '/',
        name:'BlogList',
        component: BlogList
      },
      {
        path: '/blogDetail/:id',
        name:'BlogDetail',
        component: BlogDetail
      },
      {
        path: '/timeline',
        name:'Timeline',
        component: Timeline
      },
      {
        path: '/friend',
        name:'Friend',
        component: Friend
      },
      {
        path: '/momentList',
        name:'MomentList',
        component: Moment
      },
    ]
  },

]

const router = new VueRouter({
  routes
})




router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

router.afterEach((to, from) => {
  NProgress.done();
  window.scrollTo(0,0);//路由跳转后，定位到页面顶部
})



export default router
